<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="cn.java71.util.MyBatisUtil" %>
<%@ page import="cn.java71.dao.GradeDao" %>
<%@ page import="cn.java71.entity.Grade" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: oldliu
  Date: 2021/1/25
  Time: 14:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>add a subject</title>
</head>
<body>
<%@include file="checkLogin.jsp"%>

  <form action="doAddSubject.jsp" method="post">
      <p>
          课程名:<input type="text" required name="subjectname"/>
      </p>
      <p>
          学时:<input type="number" min="1" required name="classhour"/>
      </p>
      <p>
          所属年级:
          <select name="gradeid">
              <%
                  SqlSession s= MyBatisUtil.get();
                  GradeDao gdao=s.getMapper(GradeDao.class);
                  List<Grade> all = gdao.findALL();
                  MyBatisUtil.close(s);
                  for(Grade g:all){
              %>
              <option value="<%=g.getId()%>"><%=g.getGname()%></option>
              <%}%>
          </select>
      </p>
      <p>
          <button type="submit">保存</button>
      </p>
  </form>
</body>
</html>
